import Vue from 'vue'
import Vuex from 'vuex'
import axios from "../common/axios.js"
import axios2 from "../common/axios2.js"

Vue.use(Vuex); //vue的插件机制
//Vuex.Store 构造器选项
const store = new Vuex.Store({
	state: { //存放状态
		userCertsOk:{},
		userCerts:{},
		userInfo:{},
		isLogin:false,
		leftMoney:0,
		firstLogin: true,
		reginformation: {
		            mobile: null,
		            validateCode: null,
		            password: null,
		            userName: null
		        },
		btnText: "获取验证码",
		btnDisabled: false,
		 //错误信息提示
		errorInformation: {
		    mes: '',
		    timeout: 1500,
		    icon: 'error',
		},
		//正确信息提示
		Information: {
		    mes: '',
		    timeout: 1500,
		    icon: 'success',
		},
	},
	mutations: {
		//设置错误信息
		SET_ERRORINFORMATION(state, errorInformation) {
			uni.showModal({
			    title: errorInformation.icon,
				content:errorInformation.mes		    
			})
		    state.errorInformation = errorInformation;
		},
		//设置正确信息
		SET_INFORMATION(state, Information) {
		    uni.showModal({
		        title: Information.icon,
		    	content:Information.mes	        
		    })
		    state.Information = Information;
		},
		SET_VAL: (state, bol) => {
		      state.firstLogin = bol
		    },
		SET_DISABLE: (state, dis) => {
		    state.btnDisabled = dis
		},
		SET_BTNTEXT: (state, btn) => {
		    state.btnText = btn
		},
		SET_LOGIN: (state, bol) => {
		    state.isLogin = bol
		},
		SET_USERINFO: (state, obj) => {
		    state.userInfo = obj
		},
		SET_GEETSTATUS: (state, str) => {
		    state.geetStatus = str
		},
		SET_REGINFORMATION: (state, obj) => {
		    state.reginformation = obj
		},
		SET_ITEM: (state, num) => {
		    state.selectItem = num
		},
		SET_ITEM2: (state, num) => {
		    state.selectItem2 = num
		},
		SET_ITEM3: (state, num) => {
		    state.selectItem3 = num
		},
		SET_MONEY: (state, num) => {
		    state.leftMoney = num
		},
		SET_ORDERRE: (state, obj) => {
		    state.orderPay = obj
		},
		SET_CERT: (state, obj) => {
		    state.userCerts = obj
		},
		SET_CERTOK: (state, obj) => {
		    state.userCertsOk = obj
		},
		SET_ORDER: (state, obj) => {
		    state.listUseableOrders = obj
		},
		SET_CITY: (state, obj) => {
		    state.citys = obj
		},
		SET_PICK: (state, obj) => {
		    state.picks = obj
		},
		SET_APPLY: (state, obj) => {
		    state.apply = obj
		},
		SET_XNIP: (state, obj) => {
		    state.xnip = obj
		},
		SET_MESS: (state, obj) => {
		    state.messages = obj
		},
		SET_MESSDEL: (state, obj) => {
		    state.messageDels = obj
		},
		SET_STATUS: (state, obj) => {
		    state.updStatusdel = obj
		},
		SET_CXIP: (state, obj) => {
		    state.cxip = obj
		},
	},

	actions: {
		// 获取签名
		BaidupaySign({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/trade/baidupaySign", {
					params:{
						chargeNo:userInfo.chargeNo,
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// w关联或注册登陆
		RelateAccount({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/user/wx/applet/relateOrRegister", {
					params:{
						unionId:userInfo.unionId,
						account:userInfo.account,
						password:userInfo.password,
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// w登陆
		CallBack({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/user/wx/login/appletCallBack", {
					params:{
						jsCode:userInfo.code,
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// w登陆参数
		GetCodeUrl({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/user/wx/login/applet/getMiniProgramConfig", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 抽奖
		LuckDraw({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/luckDraw", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 最新抽奖信息
		NewestUserPrize({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/newestUserPrize", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 用户确定打款
		UserPaid({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.post("/xiongmao-web/businessCetify/userPaid", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 支付是否成功
		IsSuccess({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/trade/isSuccess", {
					params:{
						chargeNo:userInfo.chargeNo,
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 代理池城市
		Vip20ListArea({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.post("/xiongmao-web/vip20/listArea", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 保存记录,定制需求
		CompanyBusinessSave({commit},{citys,type,companyName,contactsName,contactsMobile,maxFrequency,maxPickNum,dayTimes,detail}){
			return new Promise((resolve, reject) => {
				axios.post(`/xiongmao-web/companyBusiness/save`, {
					type,companyName,contactsName,contactsMobile,maxFrequency,maxPickNum,dayTimes,detail,citys
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//用户积分
		RechargeIsReceive({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/rechargeIsReceive", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//充值金额
		ThisMonthMoney({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/thisMonthMoney", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//首次浏览
		BrowseWeb({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/browseWeb", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 地址保存
		UserAddressSave({commit},{isDef,name,mobile,provinceId,cityId,region,address}){
			return new Promise((resolve, reject) => {
				console.log(isDef,name,mobile,provinceId,cityId,region,address);
				axios.post(`/xiongmao-web/userAddress/save?&isDef=${isDef}&name=${name}&mobile=${mobile}&provinceId=${provinceId}&cityId=${cityId}&region=${region}&address=${address}`, {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 地址更新
		UserAddressUpadte({commit},{id,isDel,isDef,name,mobile,provinceId,cityId,region,address}){
			return new Promise((resolve, reject) => {
				if(isDel==1){
					axios.post(`/xiongmao-web/userAddress/update?id=${id}&isDel=${isDel}`, {
					}).then((response) => {
						resolve(response)
					}).catch(error => {
						reject(error)
					})
				}else{
					axios.post(`/xiongmao-web/userAddress/update?id=${id}&isDef=${isDef}&name=${name}&mobile=${mobile}&provinceId=${provinceId}&cityId=${cityId}&region=${region}&address=${address}`, {
					}).then((response) => {
						resolve(response)
					}).catch(error => {
						reject(error)
					})
				}
				
			})
		},
		// 地址列表
		UserAddress({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/userAddress/list", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//奖品快递
		GetCourier({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/getCourier", {
					params:{
						userGoodsId:userInfo.userGoodsId,
						goodsType:userInfo.goodsType
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 我的礼品列表
		ListUserGoods({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/listUserGoods", {
					params:{
						pageNum:userInfo.pageNum,
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//兑换信息
		NewestUserGoods({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/newestUserGoods", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//商品地址
		SavePizeAddress({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/savePizeAddress", {
					params:{
						addressId:userInfo.addressId,
						pointsUserGoodsId:userInfo.pointsUserGoodsId,
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//兑换商品
		ExchangeGoods({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/exchangeGoods", {
					params:{
						addressId:userInfo.addressId,
						goodsId:userInfo.goodsId,
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 积分兑换余额
		ListPointsGoods({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/listPointsGoods", {
					params:{
						type:userInfo.type,
						pageNum:userInfo.pageNum,
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//积分明细列表
		ListPointsDetail({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/listPointsDetail", {
					params:{
						pageNum:userInfo.pageNum,
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//获取用户积分
		GetUserPoints({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/getUserPoints", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//领取积分
		ReceivePoints({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/receivePoints",{
					params:{
						signInDay:userInfo.signInDay,
						channelId:userInfo.channelId,
						rechargeSum:userInfo.rechargeSum
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 获取累积签到天数
		GetSignInDayTime({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/getSignInDayTime", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 获取签到天数
		GetSignInDay({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/getSignInDay", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 获取积分信息
		GetTaskList({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/points/getTaskList", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//查询余量
		LeftCount({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/api/leftCount", {
					params:{
						orderNo:userInfo.orderNo,
						type:userInfo.type
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//试用领取
		JsqIsReceive(){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/jsq/isReceive", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//续费金额计算
		Caculate({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/trade/caculate", {
					params:{
						orderType:userInfo.orderType,
						poolType:userInfo.poolType,
						day:userInfo.day,
						times:userInfo.times,
						minute:userInfo.minute,
						saveOrderCount:userInfo.saveOrderCount,
						orderNo:userInfo.orderNo
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 计算优惠金额
		GetFixedGift({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/wallet/getFixedGift", {
					params:{
						payMoney:userInfo.payMoney,
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 生成交易号
		BuildTrade({commit},userInfo){
			console.log(userInfo)
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/trade/buildTrade", {
					params:userInfo
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 支付
		TradeBuy({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/trade/buy", {
					params:{
						payWay:userInfo.payWay,
						chargeNo:userInfo.chargeNo,
						count:userInfo.count,
						couponId:userInfo.couponId
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//钱包充值下单
		Recharge({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/wallet/recharge", {
					params:{
						money:userInfo.money,
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//获取类型5信息
		ApplyMachine({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/selfControl/applyMachine", {
					params:{
						orderNo:userInfo.orderNo,
						secret:userInfo.secret,
						area:userInfo.area,
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//获取类型3或6信息
		SelectPickNum({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/order/selectPickNum", {
					params:{orderNo:userInfo.orderNo}
				}).then((response) => {
					resolve(response)
					if(response.data.code == '0'){
					    commit('SET_PICK', response.data.obj)
					}else{
					    commit('SET_PICK', false)
					}
				}).catch(error => {
					reject(error)
				})
			})
		},
		//获取独享城市信息
		ListCity({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/selfControl/listCity", {
					params:{
						// orderNo:userInfo.orderNo,
						// secret:userInfo.secret,
						// code:userInfo.code
					}
				}).then((response) => {
					if(response.data.code == '0'){
					    commit('SET_CITY', response.data.obj)
					}else{
					    commit('SET_CITY', false)
					}
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 获取省份
		VpnListProvince(){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/api/vpnListProvince", {					
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//获得城市
		ListProxyId({},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/api/listProxyId", {
					params:{province:userInfo.province}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})	
		},
		// 城市信息接口
		ListArea({},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/apiPlus/listArea", {
					params:{orderType:userInfo.orderType}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})	
		},
		ListStaticCity(){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/cx/listStaticCity", {					
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		ListCxCity(){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/cx/listCxCity", {					
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		ListXnArea(){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/api/listXnArea", {					
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 发票列表
		ListTrade({},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/invoices/listTrade", {
					params:{pageNum:userInfo.pageNum}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//更新营业信息
		BusinessCetifyUpdate({},{business,licenseNo,license,mobile,bankOpenName,bankAccount,bankName,bankLocation,bankBranch,types}){
			return new Promise((resolve, reject) => {
				axios.post(`/xiongmao-web/businessCetify/update?business=${business}&licenseNo=${licenseNo}&license=${license}&mobile=${mobile}&bankOpenName=${bankOpenName}&bankAccount=${bankAccount}&bankName=${bankName}&bankLocation=${bankLocation}&bankBranch=${bankBranch}&type=${types}`, {					
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 重新认证
		AgainCetify(){
			return new Promise((resolve, reject) => {
				axios.post(`/xiongmao-web/businessCetify/againCetify`, {					
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		verifyCount(){
			return new Promise((resolve, reject) => {
				axios.post(`/xiongmao-web/businessCetify/verifyCount`, {					
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 获取验证到账金额
		Verify({},{money}){
			return new Promise((resolve, reject) => {
				axios.post(`/xiongmao-web/businessCetify/verify?money=${money}`, {					
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		GetPersonalCertify(){
			return new Promise((resolve, reject) => {
				axios.post("/xiongmao-web/realNameCertify/getPersonalCertify", {					
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 上传图片
		Goimg({},{file}){
			return new Promise((resolve, reject) => {
				axios.post(`/xiongmao-web/uploadFile/image?file=${file}`, {					
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//填写人工证件审核信息
		ArtificialCertify({},{certName,certNo,frontCert,backCert,handCert,operatorsCert}){
			return new Promise((resolve, reject) => {
				axios.post(`/xiongmao-web/realNameCertify/artificialCertify?certName=${certName}&certNo=${certNo}&frontCert=${frontCert}&backCert=${backCert}&handCert=${handCert}&operatorsCert=${operatorsCert}`,)
				.then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//获取企业信息
		BusinessCetifyGet(){
			return new Promise((resolve, reject) => {
				axios.post("/xiongmao-web/businessCetify/get", {					
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 企业认证
		BusinessCetify({},{business,licenseNo,license,mobile,bankOpenName,bankAccount,bankName,bankLocation,bankBranch,types}){
			return new Promise((resolve, reject) => {
				axios.post(`/xiongmao-web/businessCetify/add?business=${business}&licenseNo=${licenseNo}&license=${license}&mobile=${mobile}&bankOpenName=${bankOpenName}&bankAccount=${bankAccount}&bankName=${bankName}&bankLocation=${bankLocation}&bankBranch=${bankBranch}&type=${types}`)
				.then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 认证次数
		GetVertifyCount(){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/realNameCertify/getVertifyCount", {					
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 优惠券列表
		ListUseableCoupon({},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/coupon/listUseableCoupon", {
					params:{
						limitMoney:userInfo.limitMoney,
						usedType:userInfo.usedType,
						}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 优惠券
		ListAllCoupon({},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/coupon/listAllCoupon", {
					params:{pageNum:userInfo.pageNum}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 城市列表
		ListCxCity(){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/cx/listCxCity", {
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 修改订单密码，获取信息
		GetCxAccount({},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/order/getCxAccount", {
					params:{orderNo:userInfo.orderNo}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 修改订单密码
		UpdateCxAccount({},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/order/updateCxAccount", {
					params:{orderNo:userInfo.orderNo,account:userInfo.account,password:userInfo.password}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 修改备注
		AddOrUpdUserOrderRemark({},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/order/addOrUpdUserOrderRemark", {
					params:{orderNo:userInfo.orderNo,remark:userInfo.remark}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 明细
		ListTradeRecord({},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/wallet/listTradeRecord", {
					params:{pageNum:userInfo.pageNum}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 获取图形验证码
		ClientStartCaptcha(){
			return new Promise((resolve, reject) => {
				axios2.get("/xiongmao-web/validateCode/ClientStartCaptcha", {				
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 修改密码
		FindPassword({},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/user/findPassword", {
					params:{mobile:userInfo.mobile,
							validateCode:userInfo.validateCode,
							newPwd:userInfo.password}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 注册
		Register({},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/user/register", {
					params:{userName:userInfo.userName,
							mobile:userInfo.mobile,
							validateCode:userInfo.validateCode,
							password:userInfo.password}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//短信验证码
		SendCode({},userInfo){
			return new Promise((resolve, reject) => {
				axios2.get("/xiongmao-web/validateCode/ClientSend", {params:{captcha:userInfo.captcha,type:userInfo.type,mobile:userInfo.mobile}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//订单列表
		OrderList({},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/order/listOrder", {params:{pageNum:userInfo.pageNum}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
						    reject(error)
						})
			})
		},
		// 有效订单
		ListUseableOrder({},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/order/listUseableOrder",{
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		//信息列表
		MessageList({},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/message/list", {params:{pageNum:userInfo.pageNum}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
						    reject(error)
						})
			})
		},
		//是否有红点消息
		MessageList2(){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/message/list", {params:{pageNum:1,status:0}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
						    reject(error)
						})
			})
		},
		// 查看消息 去红点
		UpdStatus({
			commit
        },userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/message/updStatus", {params:{ids:userInfo.id}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 查看消息
		LookMsg({
			commit
		},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/message/getById", {params:{id:userInfo.id}
				}).then((response) => {
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		},
		// 获取钱包余额
		GetMoney({
			    commit,
			    state
			}){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/wallet/leftMoney", {
				}).then((response) => {
					commit('SET_MONEY', response.data.obj)
					resolve(response)
				}).catch(error => {
						    reject(error)
						})
			})
		},
		// 获取用户实名认证返回信息
        GetCertOk({
			commit
        },userCertsOk) {
            return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/realNameCertify/getCertify", {
				}).then((response) => {
					if(response.data.code == '0'){
					    commit('SET_CERTOK', response.data.obj)
					}else{
					    commit('SET_CERTOK', false)
					}
					resolve(response)
				}).catch(error => {
						    reject(error)
						})
            })
        },
		// 常见问题
		ListTitles(){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/document/listTitles", {
				}).then((response) => {
					resolve(response.data.obj)
				}).catch(error => {
				    reject(error)
				})
			})
		},
		//文档详情
		GetDocument({commit},userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/document/getDocument", {params:{id:userInfo.id},
				}).then((response) => {
					resolve(response)
				}).catch(error => {
				    reject(error)
				})
			}) 
		},
		// 获取用户信息
		GetInfo({
		    commit
		    }, userInfo) {
		            return new Promise((resolve, reject) => {
						axios.get("/xiongmao-web/user/userInfo", {
						}).then((response) => {
							if(response.data.code==0){
								commit('SET_USERINFO', response.data.obj)
								commit('SET_LOGIN', true)
								resolve(response.data.obj)
							}else{
		                        commit('SET_LOGIN', false)
		                    }
						}).catch(error => {
						    reject(error)
						})
		            })
		},
        // 登录
        Login({commit}, 
			userInfo
		) {
            return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/user/appLogin",{ params: {account:userInfo.account,password:userInfo.password,
				originType:6
				},
				}			
				).then((response) => {
					if(response.data.code==0){
						uni.setStorage({
							key:"userInfo",
							data:userInfo
						})
						commit('SET_USERINFO', response.obj)
						commit('SET_LOGIN', true)
					}else{
						commit('SET_LOGIN', false)
					}
					resolve(response)			
				}).catch(error => {
			            reject(error)
			    })
            })
        },
		// 登出
			LogOut({
			    commit,
			    state
			}) {
			    return new Promise((resolve, reject) => {
					axios.get("/xiongmao-web/user/logout", {
					}).then((response) => {
						uni.removeStorage({
							key:"userInfo",
						})
						commit('SET_LOGIN', false)
						resolve(response)
					}).catch(error => {
			            reject(error)
			        })
			    })
			},
		//三要素认证
		TelVertify({commit}, 
			userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/realNameCertify/telVertify",{ 
					params:{certName:userInfo.certName,certNo:userInfo.certNo}
				}			
				).then((response) => {					
					resolve(response)			
				}).catch(error => {
			        reject(error)
			    })
			})
		},
		//实名认证
		GetCertifyUrl({commit}, 
			userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/realNameCertify/getCertifyUrl",{ 
					params:{certName:userInfo.certName,certNo:userInfo.certNo}
				}			
				).then((response) => {					
					resolve(response)			
				}).catch(error => {
			        reject(error)
			    })
			})
		},
		//判断认证信息是否跟上次一致
		VertifyInfoIsSame({commit}, 
			userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/realNameCertify/vertifyInfoIsSame",{ 
					params:{ mobile:userInfo.mobile,certName:userInfo.certName,certNo:userInfo.certNo}
				}			
				).then((response) => {					
					resolve(response)			
				}).catch(error => {
			        reject(error)
			    })
			})
		},
		//本机ip
		UserIp(
			commit,
			state
			){
				return new Promise((resolve, reject) => {
					axios.get('/xiongmao-web/whilteList/getUserIp',
					).then((response)=>{
						resolve(response)
					}).catch(error => {
			            reject(error)
			        })
				})
			},
		// 更换密匙
		UpdateSecret(){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/user/updateSecret",{}).then((response)=>{
					resolve(response)
				}).catch(error => {
			        reject(error)
			    })
			})
		},
		// 白名单列表
		ListUserIp(){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/whilteList/listUserIp",{}).then((response)=>{
					resolve(response)
				}).catch(error => {
			        reject(error)
			    })
			})
		},
		//清除白名单
		BatchSaveRecord({commit}, 
			userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/whilteList/batchSaveRecord",{}).then((response)=>{
					resolve(response)
				}).catch(error => {
			        reject(error)
			    })
			})
		},
		BatchSaveRecord2({commit},
			userInfo){
			return new Promise((resolve, reject) => {
				axios.get("/xiongmao-web/whilteList/batchSaveRecord",{params:{ips:userInfo.ips}}).then((response)=>{
					resolve(response)
				}).catch(error => {
			        reject(error)
			    })
			})
		}
	},
})
export default store
